package com.totoro.mall.mall_buyer.utils;

import com.totoro.mall.mall_buyer.enums.ResultEnum;
import com.totoro.mall.mall_buyer.vo.ResultVO;

/**
 * Created by Niki on 2018/4/12 8:39
 */
public class ResultVOUtil {
    public static ResultVO success(Object object) {
        ResultVO resultVO = new ResultVO();
        resultVO.setData(object);
        resultVO.setCode(ResultEnum.SUCCESS.getCode());
        resultVO.setMsg(ResultEnum.SUCCESS.getMessage());
        return resultVO;
    }

    public static ResultVO success() {
        return success(null);
    }

    public static ResultVO error(Integer code, String msg, Object object) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        resultVO.setData(object);
        return resultVO;
    }

    public static ResultVO error(Integer code, String msg) {
       return error(code, msg, null);
    }

    public static ResultVO error(ResultEnum error, Object object){
        return error(error.getCode(), error.getMessage(), object);
    }

    public static ResultVO error(ResultEnum error){
        return error(error.getCode(), error.getMessage(), null);
    }
}
